import cv2 as cv
import numpy as np

img = cv.imread('affine.jpg')
rows, cols, ch = img.shape
img[45:55, 45:55, :] = [255, 0, 0]
img[195:205, 45:55, :] = [0, 255, 0]
img[45:55, 195:205, :] = [0, 0, 255]
pts1 = np.float32([[50, 50], [200, 50], [50, 200]])
pts2 = np.float32([[10, 100], [200, 50], [100, 250]])
M = cv.getAffineTransform(pts1, pts2)
dst = cv.warpAffine(img, M, (cols, rows))
cv.imshow('img', img)
cv.imshow('dst', dst)
cv.waitKey(0)